package edu.pku.sei.autounit.reflect.java;

import java.util.Map;

import edu.pku.sei.autounit.reflect.AbstractType;
import edu.pku.sei.autounit.reflect.Enum;

public class JavaEnum extends AbstractType implements Enum{
	private String fullName;
	private String name;
	private String []constantNames;
	
	public JavaEnum(Class<?> c){
		this.fullName = c.getName();
		this.name = c.getSimpleName();
		Object [] s = c.getEnumConstants();
		constantNames  = new String[s.length];
		for(int i=0;i<s.length;i++){
			constantNames[i] = s[i].toString();
		}
	}
	
	public String getName(Map<String,String> map) {
		if(fullName.startsWith("java.lang"))
			return name;
		String f = map.get(name);
		if(f == null){
			map.put(name, fullName);
			return name;
		}
		else if(f.equals(fullName))
			return name;
		else
			return fullName;
	}
	
	
	public String getFullName() {
		return fullName;
	}

	
	public String[] getEnumConstants() {
		return constantNames;
	}
}
